package keyboard.controller.api;

import keyboaUtil.userData.MyCookie;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author 2B键盘
 * @version 1.0
 * @create: 2018-04-27 23:41
 * @desc 删除API
 **/
@Controller
@RequestMapping("/delete")
public class DeleteAPI {

    /**
     * 删除session
     *
     * @param request
     * @param response
     * @param model
     */
    @RequestMapping("/session.do")
    @ResponseBody
    public void delectSession(HttpServletRequest request, HttpServletResponse response, Model model) {
        request.getSession().invalidate();
        System.out.println("session----->delete");
    }

    /**
     * 清除cookie
     *
     * @param request
     * @param response
     * @param model
     */
    @RequestMapping("/cookie.do")
    @ResponseBody
    public void delectCookie(HttpServletRequest request, HttpServletResponse response, Model model) {
        MyCookie.deleteCookie(response);
    }
}
